#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


#define PATH "/dev/test_char_drv_01"
char buf[256] = {0};

int main()
{
    int fd = 0;
	int len = 0;
	int i = 0;

	fd = open(PATH, O_RDWR);
	if(fd < 0)
	{
		printf("open file %s error!\n", PATH);
		return -1;
	}

	while(1)
	{
		memset(buf, 0, sizeof(buf));
		len = read(fd, buf, sizeof(buf));

		printf("read len=%d\n", len);

		for(i=0; i<len; i++)
			printf("0x%x ", buf[i] & 0xFF);

		printf("\n");

		fflush(stdout);
	}

	close(fd);
	
    return 0;
}
